<template>
  <div class="dingdan">
    <!-- 头部 -->
    <header>
      <a href="javascript:history.go(-1)">
        <div class="jian"></div>
      </a>
      <input type="text" placeholder="欧式吊灯" />
      <div class="san">
        <div class="d"></div>
        <div class="d"></div>
        <div class="d"></div>
      </div>
      <div style="clear: both"></div>
    </header>

    <!-- 待收货 -->
    <div class="choice">
      <div class="box" @click="show_store = 1">
        <span :class="{ color: show_store == 1 }">全部</span>
      </div>
      <div class="box" @click="show_store = 2">
        <span :class="{ color: show_store == 2 }">待付款</span>
      </div>
      <div class="box" @click="show_store = 3">
        <span :class="{ color: show_store == 3 }">待发货</span>
      </div>
      <div class="box" @click="show_store = 4">
        <span :class="{ color: show_store == 4 }">待收货</span>
      </div>
      <div class="box" @click="show_store = 5">
        <span :class="{ color: show_store == 5 }">待评价</span>
      </div>
    </div>

    <!-- 主件 -->
    <!-- 选择内容 -->
    <div v-show="show_store == 1">
      <allProducts></allProducts>
    </div>

    <!-- 待付款 -->
    <div v-show="show_store == 2">
      <tobePaid></tobePaid>
    </div>

    <!-- 待发货 -->
    <div v-show="show_store == 3">
      <tobeDelivered></tobeDelivered>
    </div>

    <!-- 待收货 -->
    <div v-show="show_store == 4">
      <tobeReceived></tobeReceived>
    </div>

    <!-- 待评价 -->
    <div v-show="show_store == 5">
      <tobeEvaluated></tobeEvaluated>
    </div>

    <!-- 更多商品 -->
    <moveLove></moveLove>
    <!-- 底部信息 -->
    <footer>
      <div>
        <span>店铺信息</span>
        <div class="xian"></div>
      </div>
    </footer>

    <!-- 向上的图标 -->
    <div class="top_tu" v-show="top" @click="shang">
      <span></span>
    </div>
  </div>
</template>
<script>
import $ from "jquery";
import moveLove from "@/components/moveLove.vue";
import allProducts from "@/components/allProducts.vue";
import tobePaid from "@/components/tobePaid.vue";
import tobeDelivered from "@/components/tobeDelivered.vue";
import tobeReceived from "@/components/tobeReceived.vue";
import tobeEvaluated from "@/components/tobeEvaluated.vue";

export default {
  data() {
    return {
      ding: [],
      flag: false,
      count: 0,
      top: false, //置顶的图标
      xian: false, //头部
      show_store: 1, //选择商品
    };
  },
  components: {
    moveLove,
    allProducts,
    tobePaid,
    tobeDelivered,
    tobeReceived,
    tobeEvaluated,
  },
  mounted() {
    /* var that = this;
    //给勾选按钮添加isChecked
    this.ding.map((item) => {
      that.$set(item, "isChecked", true);
    }); */

    // 获取数据
    window.addEventListener("scroll", this.handleScroll, true);
    window.scrollTo(0, 0);
    this.ding = this.$store.state.ding;
    setTimeout(() => {
      // console.log(this.ding.length);
      this.count = this.ding.length;
    }, 200);
  },
  computed: {
    //动态的获取总价
    shop_Total() {
      var newShop = this.ding.filter((val) => {
          return val.isChecked;
        }),
        totals = 0;
      for (var i = 0; i < newShop.length; i++) {
        totals +=
          newShop[i].shopTotal * newShop[i].shopCount - newShop[i].shopYou;
      }
      return totals;
    },
  },
  methods: {
    yun(e, id) {
      e.target.checked
        ? (this.ding[id].shopTotal += this.ding[id].shopYun)
        : (this.ding[id].shopTotal -= this.ding[id].shopYun);
    },
    shang() {
      // 置顶
      $("html").animate(
        {
          scrollTop: 0,
        },
        200,
        "linear"
      );
    },
    //  管理显示隐藏
    handleScroll() {
      var top = Math.floor(
        document.body.scrollTop ||
          document.documentElement.scrollTop ||
          window.pageYOffset
      );
      // 向上的图标显示
      if (top > 20) {
        this.top = true;
        this.xian = true;
      } else {
        this.top = false;
        this.xian = false;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.dingdan {
  // 标题
  header {
    height: 50px;

    a {
      float: left;
      .jian {
        font-size: 18px;
        color: #5a5e6a;
        height: 50px;
        line-height: 50px;
      }
      .jian::before {
        content: "";
        width: 15px;
        height: 15px;
        border-top: 1px solid #5a5e6a;
        border-left: 1px solid #5a5e6a;
        display: inline-block;
        margin: 10px 10px 0;
        transform: rotate(-45deg);
      }
    }
    //    搜索
    input {
      width: 80%;
      height: 35px;
      line-height: 35px;
      float: left;
      margin-top: 8px;
      border-radius: 20px;
      outline: none;
      border: 1px solid;
      padding-left: 13px;
      font-size: 14px;
      border: 1px solid #f5c16a;
    }
    // 消息三点
    .san {
      float: right;
      width: 33px;
      height: 33px;
      margin-top: 9px;
      display: flex;
      flex-flow: column;
      justify-content: space-evenly;
      align-items: center;
      .d {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: #454545;
      }
    }
  }
  // 待收货
  .choice {
    height: 50px;
    // border: 1px solid black;
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 13px;
    margin: 15px 0;
    .box {
      width: 60px;
      height: 86%;
      line-height: 50px;
      text-align: center;
      font-size: 14px;
    }
    .color {
      display: inline-block;
      height: 42px;
      color: #b1843b;
      border-bottom: 2px solid #b1843b;
    }
  }

  //   购买的商品
  .gmd {
    margin: 15px 15px 0 15px;
    border-radius: 10px;
    background-color: #fff;
    padding-bottom: 15px;
    .top {
      height: 50px;
      line-height: 50px;
      font-size: 15px;
      .img {
        margin: 12px 10px;
        width: 25px;
        height: 25px;
        background: url(/img/logo.9f4a35a3.png) -22px -5px no-repeat;
        background-size: 288%;
        float: left;
      }
      // 箭头
      .arrow {
        width: 8px;
        height: 8px;
        border-top: 1px solid #d6d6d6;
        border-left: 1px solid #d6d6d6;
        display: inline-block;
        margin: 10px 10px 0;
        transform: rotate(135deg);
      }
      // 商家
      .store {
        margin-left: 108px;
        font-size: 13px;
        color: #ffa863;
      }
    }
    // tupian
    .middle {
      // width: 100px;
      height: 100px;
      img {
        width: 100px;
        height: 100px;
        float: left;
        border: 1px solid #c6c6c6;
        margin: 0 10px;
        border-radius: 5px;
      }
      .r {
        font-size: 13px;
        width: 150px;
        float: left;
        p {
          color: #353535;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .kuan {
          margin-top: 10px;
          // background-color: #fafafa;
          color: #c6c6c6;
          border-radius: 5px;
        }
        // 48小时内发货
        .time {
          margin-top: 5px;
          color: #df8842;
        }
      }
      .qian {
        float: right;
        margin-right: 15px;
        p {
          font-size: 15px;
          span {
            font-size: 13px;
            float: right;
            color: #b7b7b7;
          }
        }
      }
    }
    // 下面的内容
    .bottom {
      font-size: 13px;
      p {
        margin: 15px 0;
        .pei {
          margin-right: 10px;
        }
        .pu {
          color: #b7b7b7;
        }
        .kuai {
          margin-left: 105px;
        }
        .jian_t {
          width: 8px;
          height: 8px;
          border-top: 1px solid #d5d5d5;
          border-left: 1px solid #d5d5d5;
          display: inline-block;
          margin-left: 10px;
          transform: rotate(135deg);
        }
      }
      .yun {
        .kuai {
          font-size: 15px;
          margin-left: 76px;
        }
        // 选中的情况
        input {
          width: 13px;
          height: 13px;
          margin-left: 10px;
          position: relative;
          &::before {
            content: "";
            position: absolute;
            background: url("../../public/img/check.png") no-repeat;
            background-size: 100%;
            width: 15px;
            height: 15px;
            display: inline-block;
            top: -1px;
            left: -1px;
          }
        }
        // 未选中的状态
        input:checked {
          width: 13px;
          height: 13px;
          margin-right: 10px;
          position: relative;
          &::before {
            content: "";
            position: absolute;
            background: url("../../public/img/check1.png") no-repeat;
            background-size: 100%;
            width: 15px;
            height: 15px;
            display: inline-block;
            top: -1px;
            left: -1px;
          }
        }
      }
      .dian {
        .kuai {
          color: #ffa863;
          font-size: 15px;
          margin-left: 97px;
        }
      }
      .ding {
        input {
          outline: none;
          border: transparent;
          width: 230px;
        }
        input:focus::-webkit-input-placeholder {
          color: transparent;
        }
        input::-webkit-input-placeholder {
          color: #adadad;
        }
      }
      .gong {
        margin-bottom: 10px;
        .pu {
          margin-left: 94px;
        }
        .kuai {
          margin-left: 5px;
        }
        .ji {
          color: #000;
          font-size: 15px;
        }
      }
    }
    // 确定收货
    .define {
      margin: 15px 10px 0;
      span {
        font-size: 12px;
      }
      .more {
        color: #afafaf;
      }
      .box {
        border: 1px solid #ededed;
        padding: 6px 15px;
        border-radius: 25px;
        margin: 0 5px 0 20px;
      }
      .box1 {
        border: 1px solid #ededed;
        padding: 6px 15px;
        border-radius: 25px;
        margin: 0 5px;
      }
      .color {
        color: #ffa863;
        border: 1px solid #ffa863;
      }
    }
  }

  /* 底部信息 */
  footer {
    width: 100%;
    height: 150px;
    margin-top: 1.332623rem;
    background-color: #efeff4;
    div {
      width: 80%;
      margin: auto;
      text-align: center;
      line-height: 2.665245rem;
      font-size: 16px;
      color: #b7b7b9;
      position: relative;
      span {
        display: inline-block;
        background-color: #efeff4;
        position: relative;
        z-index: 2;
        width: 85px;
      }
      .xian {
        width: 100%;
        border-top: 1px solid #d3d3d4;
        position: absolute;
        top: 50%;
        margin: auto;
      } //footer
    }
  }
  // 置顶图标
  .top_tu {
    width: 1.066098rem;
    height: 1.066098rem;
    border: 0.026652rem solid transparent;
    position: fixed;
    bottom: 70px;
    right: 15px;
    border-radius: 20px;
    background: rgba(151, 113, 37, 0.2);
    text-align: center;
    /* line-height: 15px; */
    display: flex;
    justify-content: center;
    align-items: center;
    span {
      display: inline-block;
      width: 15px;
      height: 15px;
      border-left: 2px solid #977125;
      border-top: 2px solid #977125;
      transform: rotate(45deg);
      margin-top: 6px;
    }
  }
}
</style>